package light.head.dao.sys;

import java.util.List;

import light.head.framework.base.BaseDAO;
import light.head.model.MessageReceive;
import light.head.model.MessageReceivePK;

import org.springframework.stereotype.Service;

@Service
public class MessageReceiveDAO extends BaseDAO<MessageReceive, MessageReceivePK> {

	private final static String sql_findByMessageCode = "FROM MessageReceive mr WHERE mr.mc = ?";
	private final static String sql_findByMessageCodeRuc = "FROM MessageReceive mr WHERE mr.mc = ? AND mr.ruc= ?";
	private final static String sql_findByCu = "FROM MessageReceive mr WHERE mr.iv = 0 AND mr.ruc= ?";
	
	
	/**
	 * 根据消息编号获取相关的MessageReceive
	 * @param	消息编号
	 */
	public List<MessageReceive> findByMessageCode(Integer code) {
		List<MessageReceive> list = find(sql_findByMessageCode, code);
		return list;
	}
	/**
	 * 根据消息编号接受人获取相关的MessageReceive对象
	 * @param	消息编号
	 */
	public MessageReceive findMesssageReceiveByMessageCodeRuc(Integer code, Integer ruc) {
		Object o = get(sql_findByMessageCodeRuc,code, ruc);
		return (MessageReceive)o;
	}
	/**
	 * 根据消息编号获取所有未读的消息
	 * @param	消息编号
	 */
	public List<MessageReceive> findByCu(Integer code) {
		List<MessageReceive> list = find(sql_findByCu, code);
		return list;
	}
}
